package com.example.activitysign.controller;

import com.example.activitysign.pages.AjaxResult;
import com.example.activitysign.service.IActivityAwardRuleService;
import com.example.activitysign.validate.ActivityAwardRuleCreateValidate;
import com.example.activitysign.validate.ActivityAwardRuleUpdateValidate;
import com.example.activitysign.vo.activity.ActivityAwardRuleDetailVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 奖励规则管理
 */
@Slf4j
@RestController
@RequestMapping("api/activityAwardRule")
public class ActivityAwardRuleController {

    @Resource
    private IActivityAwardRuleService iActivityAwardRuleService;


    @GetMapping("/detail")
    public AjaxResult<ActivityAwardRuleDetailVo> detail(@Validated @RequestParam("id") Long id) {
        ActivityAwardRuleDetailVo detail = iActivityAwardRuleService.detail(id);
        return AjaxResult.success(detail);
    }

    /**
     * 奖励规则新增
     *
     * @param createValidate
     * @return
     */
    @PostMapping("/add")
    public AjaxResult<Object> add(@Validated @RequestBody ActivityAwardRuleCreateValidate createValidate) {
        iActivityAwardRuleService.add(createValidate);
        return AjaxResult.success();
    }

    /**
     * 奖励规则编辑
     *
     * @param updateValidate
     * @return
     */
    @PostMapping("/edit")
    public AjaxResult<Object> edit(@Validated @RequestBody ActivityAwardRuleUpdateValidate updateValidate) {
        iActivityAwardRuleService.edit(updateValidate);
        return AjaxResult.success();
    }


}
